home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / telecom / 46 / pascal / peekpoke.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-08-15  |  2.2 KB  |  109 lines

  1. { peekpoke.pas - Include this file  when you compile to implement PEEK and
  2.     POKE functions. }
  3.  
  4.   {$P-}
  5.  
  6.   FUNCTION peek( address: long_integer ): long_integer;
  7.  
  8.     TYPE
  9.       byte_ptr = ^byte;
  10.  
  11.     VAR
  12.       funny: RECORD
  13.                CASE boolean OF
  14.                  true:  ( a: long_integer );
  15.                  false: ( p: byte_ptr );
  16.              END;
  17.  
  18.     BEGIN
  19.       funny.a := address;
  20.       peek := funny.p^;
  21.     END;
  22.  
  23.   FUNCTION wpeek( address: long_integer ): long_integer;
  24.  
  25.     TYPE
  26.       int_ptr = ^integer;
  27.  
  28.     VAR
  29.       funny: RECORD
  30.                CASE boolean OF
  31.                  true:  ( a: long_integer );
  32.                  false: ( p: int_ptr );
  33.              END;
  34.  
  35.     BEGIN
  36.       funny.a := address;
  37.       wpeek := funny.p^;
  38.     END;
  39.  
  40.   FUNCTION lpeek( address: long_integer ): long_integer;
  41.  
  42.     TYPE
  43.       lint_ptr = ^long_integer;
  44.  
  45.     VAR
  46.       funny: RECORD
  47.                CASE boolean OF
  48.                  true:  ( a: long_integer );
  49.                  false: ( p: lint_ptr );
  50.              END;
  51.  
  52.     BEGIN
  53.       funny.a := address;
  54.       lpeek := funny.p^;
  55.     END;
  56.  
  57.   PROCEDURE poke( address: long_integer; value: byte );
  58.  
  59.     TYPE
  60.       lint_ptr = ^long_integer;
  61.  
  62.     VAR
  63.       funny: RECORD
  64.                CASE boolean OF
  65.                  true:  ( a: long_integer );
  66.                  false: ( p: lint_ptr );
  67.              END;
  68.  
  69.     BEGIN
  70.       funny.a := address;
  71.       funny.p^ := value;
  72.     END;
  73.  
  74.   PROCEDURE wpoke( address: long_integer; value: integer );
  75.  
  76.     TYPE
  77.       int_ptr = ^integer;
  78.  
  79.     VAR
  80.       funny: RECORD
  81.                CASE boolean OF
  82.                  true:  ( a: long_integer );
  83.                  false: ( p: int_ptr );
  84.              END;
  85.  
  86.     BEGIN
  87.       funny.a := address;
  88.       funny.p^ := value;
  89.     END;
  90.  
  91.   PROCEDURE lpoke( address, value: long_integer );
  92.  
  93.     TYPE
  94.       lint_ptr = ^long_integer;
  95.  
  96.     VAR
  97.       funny: RECORD
  98.                CASE boolean OF
  99.                  true:  ( a: long_integer );
  100.                  false: ( p: lint_ptr );
  101.              END;
  102.  
  103.     BEGIN
  104.       funny.a := address;
  105.       funny.p^ := value;
  106.     END;
  107.  
  108.   {$P=}
  109.